package com.ttnet.model;

import java.util.Comparator;
import java.util.StringTokenizer;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "FOOTBALL")
public class Football extends BaseModel implements Comparable<Football> {

	private int rowNum;
	private String team;
	private int P;
	private int W;
	private int L;
	private int D;
	private int F;
	private int A;
	private int pts;

	public Football(String token) {
		StringTokenizer st = new StringTokenizer(token);
		rowNum = Integer.valueOf(st.nextToken().replace(".", ""));
		team = st.nextToken();
		P = Integer.valueOf(st.nextToken());
		W = Integer.valueOf(st.nextToken());
		L = Integer.valueOf(st.nextToken());
		D = Integer.valueOf(st.nextToken());
		F = Integer.valueOf(st.nextToken());
		A = Integer.valueOf(st.nextToken());
		pts = Integer.valueOf(st.nextToken());
	}

	@Override
	public int compareTo(Football o) {
		int a = this.A - this.F;
		int b = o.A - o.F;

		if (a < 0)
			return b;
		else if (b < 0)
			return a;
		else {
			return a - b;
		}
	}

	public static Comparator<Football> FootballOriginalComparator = new Comparator<Football>() {

		public int compare(Football football1, Football football2) {

			return football1.compareTo(football2);
		}

	};

	public int getRowNum() {
		return rowNum;
	}

	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}

	public String getTeam() {
		return team;
	}

	public void setTeam(String team) {
		this.team = team;
	}

	public int getP() {
		return P;
	}

	public void setP(int p) {
		P = p;
	}

	public int getW() {
		return W;
	}

	public void setW(int w) {
		W = w;
	}

	public int getL() {
		return L;
	}

	public void setL(int l) {
		L = l;
	}

	public int getD() {
		return D;
	}

	public void setD(int d) {
		D = d;
	}

	public int getF() {
		return F;
	}

	public void setF(int f) {
		F = f;
	}

	public int getA() {
		return A;
	}

	public void setA(int a) {
		A = a;
	}

	public int getPts() {
		return pts;
	}

	public void setPts(int pts) {
		this.pts = pts;
	}

	public static Comparator<Football> getFootballOriginalComparator() {
		return FootballOriginalComparator;
	}

	public static void setFootballOriginalComparator(Comparator<Football> footballOriginalComparator) {
		FootballOriginalComparator = footballOriginalComparator;
	}

}
